#pragma once
#include<string>
#include<iostream>
using namespace std;

const int defaultvalue = 0;
enum
{
    ok = 0,
    div_zero,
    mod_zero,
    unknow
};

const string opers="+-*/%()&";

class Task
{
public:
    Task() {}
    Task(int x, int y, char op) : _x(x), _y(y), oper(op), result(defaultvalue), code(ok)
    {
    }

    void Run()
    {
        switch (oper)
        {
        case '+':
            result = _x + _y;
            break;
        case '-':
            result = _x - _y;
            break;
        case '*':
            result = _x * _y;
            break;
        case '/':
        {
            if (_y == 0)
                code = div_zero;
            else
                result = _x / _y;
        }
        break;
        case '%':
        {
            if (_y == 0)
                code = mod_zero;
            else
                result = _x % _y;
        }
        break;
        default:
            code = unknow;
            break;
        }
    }

    string Printtask()
    {
        string s;
        s=to_string(_x);
        s+=oper;
        s+=to_string(_y);
        s+="=?";

        return s;
    }

    string Printresult()
    {
        string s;
        s=to_string(_x);
        s+=oper;
        s+=to_string(_y);
        s+="=";
        s+=to_string(result);
        s+="[";
        s+=to_string(code);
        s+="]";

        return s;
    }

    ~Task()
    {
    }

private:
    int _x;
    int _y;
    char oper;

    int result;
    int code; // 结果码 结果可信度：0:结果可信 非0:不可信
};